package com.lazy.demo1;


import com.lazy.demo1.handler.GidNetContext;
import com.lazy.demo1.handler.GidNetListener;
import com.lazy.lib.net.tcp.server.TcpServer;
import com.lazy.lib.util.DataQueue;

public class DemoTcpServer {

    public static void main(String[] args){
        int port = 8023;
        if (args.length == 1) {
            port = Integer.valueOf(args[0]);
        }
        TcpServer server = new TcpServer(port);
        DataQueue<byte[]> dataQueue = new DataQueue<byte[]>();
        GidNetContext netContext = new GidNetContext();
        netContext.setListener(new GidNetListener(dataQueue));
        server.setNetContext(netContext);
        
//        ScheduledExecutorService scheduledExecutor  = Executors.newScheduledThreadPool(8);
//        scheduledExecutor.scheduleAtFixedRate(new ConsumeTask(dataQueue), 0, 1, TimeUnit.SECONDS);
        try{
            server.start();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}
